package com.wsoft.hr.pm.controller;

import com.github.pagehelper.PageInfo;
import com.wsoft.hr.pm.entity.HrPmGradeMemberEntity;
import com.wsoft.hr.pm.query.grade.member.HrPmGradeRemoveMemberInsertQuery;
import com.wsoft.hr.pm.query.grade.member.HrPmGradeRemoveMemberListQuery;
import com.wsoft.hr.pm.service.IHrPmGradeMemberService;
import com.wsoft.response.ResponsePage;
import com.wsoft.response.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 考核评级人员表 Controller
 *
 * @Author Z001
 * @Date 2025-03-01 08:35:23
 */
@RestController
@Tag(name = "考核评级人员表")
@RequestMapping("/hr/pm/grade/member")
public class HrPmGradeMemberController {

    @Resource
    private IHrPmGradeMemberService hrPmGradeMemberService;

    @Operation(summary = "获取移除人员列表", description = "移除人员列表")
    @PostMapping("/removeMemberList")
    public ResponseResult removeMemberList(@RequestBody @Valid HrPmGradeRemoveMemberListQuery query) {
        PageInfo<HrPmGradeMemberEntity> page = hrPmGradeMemberService.removeMemberList(query);
        return ResponseResult.success(ResponsePage.restPage(page));
    }


    @Operation(summary = "新增-考核评级人员表", description = "新增-考核评级人员表")
    @PostMapping("/insert")
    public ResponseResult insert(@RequestBody @Valid HrPmGradeRemoveMemberInsertQuery query) {
        boolean b =  hrPmGradeMemberService.insertHrPmGradeMember(query);
        if (b) {
            return ResponseResult.success("[sys.msg.success]");
        } else {
            return ResponseResult.failed("[sys.msg.failed]");
        }
    }

    @Operation(summary = "删除-考核评级人员表",description = "删除-考核评级人员表")
    @GetMapping("/delete")
    public ResponseResult delete(@RequestParam("id") Long id) {
        boolean b = hrPmGradeMemberService.delete(id);
        if (b) {
            return ResponseResult.success("[sys.msg.success]");
        } else {
            return ResponseResult.failed("[sys.msg.failed]");
        }
    }
}
